Skip to content

Conversation

@0xNeshi
Copy link
Collaborator

@0xNeshi 0xNeshi commented Nov 17, 2025

Resolves #56
Resolves #76
Resolves #5
Resolves #155

@0xNeshi 0xNeshi self-assigned this Nov 17, 2025
Comment on lines 381 to 388
let sync_handler = SyncHandler::new(
self.provider.clone(),
self.max_block_range,
start_id,
block_confirmations,
sender,
);
sync_handler.run().await
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a strategy-like pattern that we could use for mode handling. The logic is all contained within the strategy type.

@0xNeshi 0xNeshi marked this pull request as draft November 21, 2025 09:25
@0xNeshi 0xNeshi marked this pull request as ready for review November 24, 2025 06:03
@0xNeshi
Copy link
Collaborator Author

0xNeshi commented Nov 24, 2025

Depends on #205 , but can be reviewed independently even now

EDIT: #205 will solve test failures such as https://github.com/OpenZeppelin/Event-Scanner/actions/runs/19633672074/job/56219119078?pr=187, it's an issue with the test setup

@0xNeshi 0xNeshi marked this pull request as draft November 25, 2025 07:23
0xNeshi added a commit that referenced this pull request Nov 26, 2025
@0xNeshi 0xNeshi marked this pull request as ready for review November 26, 2025 07:30
Copy link
Collaborator

@LeoPatOZ LeoPatOZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving these here for now, these are mostly very very initials thoughts just as i was reading through the PR (hence why they seem to be so disjunct).

Next couples of passes should hopefully be more focused on individual flows

block_confirmations: u64,
max_block_range: u64,
reorg_handler: &mut ReorgHandler<N>,
notify_after_first_block: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I feel like a lot of the these common function have similar arguments. Perhaps it would be nicer to define a stream config struct or similar, and pass that in?

pub(crate) async fn stream_live_blocks<N: Network>( 
    stream_config: StreamConfig,
    notify_after_first_block: bool,
)

hopefully can be reduced to something like this? (didnt check which params are shared between the fns)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe can be shared with sync_handler.rs as well (seems to share similar fields)

Copy link
Collaborator

@LeoPatOZ LeoPatOZ Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we extracted these functions out of the block range scanner too preemptively?

I feel like they need so many of the same arguments that the block range scanner contains that it may as well be an impl of the connected scanner itself? Maybe in that case we have the reorg handler be a field of the block range scanner?

Im not exactly sure what the cleanest way to approach this is :(

We can also think about separating the block range scanner by type just like the event scanner. We could have LiveBlockRangeScanner SyncFromBlockRange etc.. Perhaps it would make our lives easier

Apologies Im just thinking out loud so im putting my thoughts here for now

Copy link
Collaborator Author

@0xNeshi 0xNeshi Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything you wrote makes complete sense, and were it not for the fact that with parallelization the whole of block range scanner will probably become redundant, I would've applied every suggestion.
Currently it makes no sense to invest more time into refactoring any of its components.

&mut self,
block: &N::BlockResponse,
) -> Result<Option<N::BlockResponse>, ScannerError> {
let block = block.header();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was thinking about #102

Perhaps this check could be skipped if block num < finalised ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd need to eagerly fetch finalized block (1 RPC call) and if block num > finalised, we'd need to perform another RPC call to perform the current check (2 RPC calls in total).

Currently, we only ever perform 1 RPC call.

Comment on lines +302 to +305
batch_count += 1;
if batch_count % 10 == 0 {
debug!(batch_count = batch_count, "Processed historical batches");
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: do you mind if we remove this not sure its that helpful and makes the fn harder to read imo

Maybe this info can be emitted in a different log

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to intentionally introduce unrelated changes to the PR. If you have an idea where this could be emitted instead, feel free to open a small PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement Improvement to existing functionality type: feature New functionality type: refactor Code improvement without changing functionality

Projects

None yet

3 participants